package model;

import java.io.Serializable;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author ZimmE
 */
@Entity
@Table(name = "person_competence")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "PersonCompetence.findAll", query = "SELECT p FROM PersonCompetence p"),
    @NamedQuery(name = "PersonCompetence.findByPersonCompetenceId", query = "SELECT p FROM PersonCompetence p WHERE p.personCompetenceId = :personCompetenceId"),
    @NamedQuery(name = "PersonCompetence.findByYearsOfExperience", query = "SELECT p FROM PersonCompetence p WHERE p.yearsOfExperience = :yearsOfExperience")})
public class PersonCompetence implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "person_competence_id")
    private Integer personCompetenceId;
    @Basic(optional = false)
    @NotNull
    @Column(name = "years_of_experience")
    private int yearsOfExperience;
    @JoinColumn(name = "competence_id", referencedColumnName = "competence_id")
    @ManyToOne(optional = false)
    private Competence competenceId;
    @JoinColumn(name = "person_id", referencedColumnName = "person_id")
    @ManyToOne(optional = false)
    private Person personId;

    public PersonCompetence() {
    }

    public PersonCompetence(Integer personCompetenceId) {
        this.personCompetenceId = personCompetenceId;
    }

    public PersonCompetence(Integer personCompetenceId, int yearsOfExperience) {
        this.personCompetenceId = personCompetenceId;
        this.yearsOfExperience = yearsOfExperience;
    }

    public Integer getPersonCompetenceId() {
        return personCompetenceId;
    }

    public void setPersonCompetenceId(Integer personCompetenceId) {
        this.personCompetenceId = personCompetenceId;
    }

    public int getYearsOfExperience() {
        return yearsOfExperience;
    }

    public void setYearsOfExperience(int yearsOfExperience) {
        this.yearsOfExperience = yearsOfExperience;
    }

    public Competence getCompetenceId() {
        return competenceId;
    }

    public void setCompetenceId(Competence competenceId) {
        this.competenceId = competenceId;
    }

    public Person getPersonId() {
        return personId;
    }

    public void setPersonId(Person personId) {
        this.personId = personId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (personCompetenceId != null ? personCompetenceId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PersonCompetence)) {
            return false;
        }
        PersonCompetence other = (PersonCompetence) object;
        if ((this.personCompetenceId == null && other.personCompetenceId != null) || (this.personCompetenceId != null && !this.personCompetenceId.equals(other.personCompetenceId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.PersonCompetence[ personCompetenceId=" + personCompetenceId + " ]";
    }
}
